package cn.wolfcode.service.impl;

import cn.wolfcode.domain.ExamQuestion;
import cn.wolfcode.mapper.ExamQuestionMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IExamQuestionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExamQuestionServiceImpl implements IExamQuestionService {

    @Autowired
    private ExamQuestionMapper examQuestionMapper;


    @Override
    public void save(ExamQuestion examQuestion) {
        examQuestionMapper.insert(examQuestion);
    }

    @Override
    public void delete(Long id) {

    }

    @Override
    public void update(ExamQuestion examQuestion) {

    }

    @Override
    public ExamQuestion get(Long id) {
        return null;
    }

    @Override
    public List<ExamQuestion> listAll() {
        return examQuestionMapper.selectAll();
    }

    @Override
    public PageInfo<ExamQuestion> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); //对下一句sql进行自动分页
        List<ExamQuestion> examQuestions = examQuestionMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<ExamQuestion>(examQuestions);
    }
}
